// 2025/09/24
// Author: Forever
#include <bits/stdc++.h>
using namespace std;

#define int long long
int n, dp[300005];
vector<int> g[300005];

bool dfs(int u, int fa, int k)
{
    dp[u] = dp[fa] + k - (g[u].size() - (fa != 0));
    if (dp[u] < 0)
        return false;
    for (int i = 0; i < g[u].size(); i++) {
        int v = g[u][i];
        if (v == fa)
            continue;
        if (!dfs(v, u, k))
            return false;
    }
    return true;
}

signed main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin >> n;
    for (int i = 1; i < n; i++) {
        int u, v;
        cin >> u >> v;
        g[u].push_back(v);
        g[v].push_back(u);
    }
    int l = 1, r = n;
    while (l <= r){
        memset(dp, 0, sizeof(dp));
        int mid = (l + r) >> 1;
        if (dfs(1, 0, mid))
            r = mid - 1;
        else
            l = mid + 1;
    }
    cout << l << endl;
    return 0;
}